/*
 * InvulgoTracker
 * Copyright (C) Thomas Andersen 2011 <thomas.1.andersen@gmail.com>
 *
 * InvulgoTracker is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * InvulgoTracker is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more TASK_PROGRESSs.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TASK_PROGRESS_VIEW_H_
#define _TASK_PROGRESS_VIEW_H_

#include <gtk/gtk.h>
#include "task-time.h"
#include "taskid.h"

class TaskProgressView
{
public:
    TaskProgressView();
    virtual ~TaskProgressView();
    void Init(GtkWidget *view);
    void Restart();
    void Calc();
    bool GetFirst(gchar **name, gchar **timeStr, gchar **usedStr, gchar **pct);
    bool GetNext(gchar **name, gchar **timeStr, gchar **usedStr, gchar **pct);
protected:

private:
    void Clean();
    void ColumnClicked(GtkTreeViewColumn *treeViewColumn, gint columnSortId);
    static gint sort_iter_compare_func (GtkTreeModel *model, GtkTreeIter  *a, GtkTreeIter  *b, gpointer userdata);
    static void column_time_clicked(GtkTreeViewColumn *treeviewcolumn, gpointer user_data);
    static void column_title_clicked(GtkTreeViewColumn *treeviewcolumn, gpointer user_data);
    static void column_used_clicked(GtkTreeViewColumn *treeviewcolumn, gpointer user_data);
    enum
    {
        COL_TITLE,
        COL_TIME,
        COL_USED,
        COL_PCT,
        COL_PCTTEXT,
        COL_ID,
        NUM_COLS
    };
    enum
    {
        SORT_TITLE,
        SORT_TIME,
        SORT_USED,
        SORT_PCT
    };

    GtkTreeModel *CreateModel();

    GtkTreeView *view;
    GtkTreeModel *model;
    GtkTreeIter currentIter;
    guint year,month,day;
    TaskTime *prevTime;
    GtkTreeIter prevIter;
};

#endif // _TASK_PROGRESS_VIEW_H_
